package com.zs.ktsms.service.impl;

import com.zs.ktsms.mapper.StorageRecordMapper;
import com.zs.ktsms.pojo.Address;
import com.zs.ktsms.pojo.StorageRecord;
import com.zs.ktsms.service.StorageRecordService;
import com.zs.ktsms.utils.Page;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author ZhouShuang
 * @version 17
 * @Title
 * @date 2025/5/31 下午9:27
 */
@Service
public class StorageRecordServiceImpl implements StorageRecordService {

    @Resource
    private StorageRecordMapper mapper;

    /**
     * 获取分页数据
     *
     * @param goodsName
     * @param supplierId
     * @param payStatus
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public Page<StorageRecord> getPage(String goodsName, Long supplierId, Integer payStatus, Integer pageNo, Integer pageSize) {
        Page<StorageRecord> page = new Page<>();
        page.setPageSize(pageSize);
        page.setTotalCount(mapper.count(goodsName,supplierId,payStatus));
        page.setPageNo(pageNo);
        int offset = (page.getPageNo()-1)*page.getPageSize();
        page.setData(mapper.selectAll(goodsName,supplierId,payStatus,offset,page.getPageSize()));
        return page;
    }

    /**
     * 添加
     *
     * @param storageRecord
     * @return
     */
    @Override
    public int add(StorageRecord storageRecord) {
        return mapper.add(storageRecord);
    }

    /**
     * 详情
     *
     * @param id
     * @return
     */
    @Override
    public StorageRecord detail(Integer id) {
        return mapper.detail(id);
    }

    /**
     * 修改
     *
     * @param storageRecord
     * @return
     */
    @Override
    public int update(StorageRecord storageRecord) {
        return mapper.update(storageRecord);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public int delete(Integer id) {
        return mapper.delete(id);
    }
}
